package com.haidong;

import com.haidong.config.SpringConfig;
import com.haidong.dao.BookDao;
import com.haidong.service.BookService;
import com.haidong.service.impl.BookServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import javax.sql.DataSource;

public class AppForAnnotation {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = new
                AnnotationConfigApplicationContext(SpringConfig.class);
//        BookDao bookDao = (BookDao) ctx.getBean("bookDao");
//        bookDao.run();
        BookService bookService = ctx.getBean(BookServiceImpl.class);
        bookService.save();

        DataSource dataSource = ctx.getBean(DataSource.class);
        System.out.println(dataSource);
        ctx.close();
    }
}
